module vlib.util.Log;

import vlib.Types;

private import
	tango.io.Stdout ;
private import  tango.stdc.stdio ;

struct vLog {
	static private {
		void*	_in, _out, _err ;
	}
	
	static void Init() {
		version( Windows) {
			_out	= GetStdHandle(STD_OUTPUT_HANDLE) ;
			_in	= GetStdHandle(STD_INPUT_HANDLE) ;
			_err	= GetStdHandle(STD_ERROR_HANDLE) ;
		} else {
			static assert(false);
		}
	}
	
	static void opCall(vBuffer bu) {
		char[] tmp	= cast(char[]) bu.slice;
		Stdout(tmp).flush;
	}
}

void log(char[] file, int line, T...)(T t){
	synchronized {
		Thread th	= Thread.getThis;
		Stdout.format("({:x}:{}:{}) ", cast(void*)th, file[0..$-2], line) ;
		Stdout.formatln(t).flush;
	}
}


void log0(T...)(T t){
	synchronized {
		Stdout.format(t).flush;
	}
}

void logn(T...)(T t){
	synchronized {
		Stdout.formatln(t).flush;
	}
}
void lg(T...)(T t){
	synchronized {
		Stdout.formatln(t).flush;
	}
}